Running Migrations from the NHibernate Designer

To run migrations from the NHibernate designer:

NHibernate will figure out whether to run the Up or Down migrations depending on the current database version.
 

Choosing the Migration Target

Before you first run migrations, you need to choose the target database. To do this:

If you subsequently change the migration target, to run the migrations against a different database, choose the Change button again and re-run the wizard.

Running Migrations from the Command Line

To run migrations from the command line, run the nhmigrate.exe program. You can find this in your migration project, under the Runner folder. nhmigrate compiles migration source code files from the current directory. (In this case you do not need to build the migrations yourself.)

The syntax for nhmigrate is:

nhmigrate provider_name connection_string [to_version]

provider_name: The type of database. See below for permitted values.

connection_string: The database connection string.

to_version: The version to which to migrate the database. If omitted, the latest version will be selected.

NHibernate will figure out whether to run the Up or Down migrations depending on the current database version.
 

Command Line Provider Names

nhmigrate supports the following values for the /p option:

Value Database Shortcut
MySql5 MySQL mysql
Oracle9 Oracle oracle
PostgreSql8 PostgreSQL pg
Sqlite3 SQLite sqlite
SqlServer2000 Microsoft SQL Server 2000 sql2000
SqlServer2005 Microsoft SQL Server 2005/8 sql
SqlServerCE Microsoft SQL Server Compact sqlce
VistaDB4 VistaDB vdb4
VistaDB3 VistaDB (3.0 file format) vdb3